package com.example.boss.pinkdiary;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;

import com.example.boss.db.gen.DaoMaster;
import com.example.boss.db.gen.DaoSession;
import com.example.boss.db.gen.diaryPwd;
import com.example.boss.db.gen.diaryPwdDao;

import java.util.List;

/**
 * Created by 打好boss on 2018/6/17.
 */

public class enterView extends Activity {
    private final long SPLASH_LENGTH = 2000;
    Handler handler = new Handler();
    // GreenDAO使用的变量
    private SQLiteDatabase db1;
    private DaoMaster daoMaster1;
    private DaoSession daoSession1;
    private diaryPwdDao dpd;
    private diaryPwd dp;
    private diaryPwdDaoHelper dpdh;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.farst_img);
        InitDAO_pwd();
        Long listNum;
        listNum=dpdh.selectNUm();
        if (listNum==0) {// 第一次则跳转到欢迎页面
            Intent intent = new Intent(enterView.this, registerDiary.class);
            startActivity(intent);
            finish();
        } else {//如果是第二次启动则直接跳转到主页面
            Intent intent = new Intent(enterView.this, PinkMain.class);
            startActivity(intent);
            finish();
        }
    }
    private void InitDAO_pwd() {
        DaoMaster.DevOpenHelper helper1 = new DaoMaster.DevOpenHelper(this, "diary_Pwd.db", null);
        db1 = helper1.getWritableDatabase();
        daoMaster1 = new DaoMaster(db1);//代表着一个数据库的连接
        daoSession1 = daoMaster1.newSession();//可以让我们使用一些Entity的基本操作和获取Dao操作类
        dpd = daoSession1.getDiaryPwdDao();
        dpdh=new diaryPwdDaoHelper(dpd);
    }

}
